import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';

dayjs.locale('zh-cn');
const isoWeek = require('dayjs/plugin/isoWeek');

dayjs.extend(isoWeek);

export const getWeeks = () => {
  const dayjs_copy: any = dayjs();
  const result: string[] = [];
  for (let i = 1; i < 8; i += 1) {
    result.push(dayjs_copy.isoWeekday(i).format('YYYY-MM-DD'));
  }
  return result;
};

export const getMonths = () => {
  const result: string[] = [];
  const year = dayjs().get('year');
  const month = dayjs().get('month') + 1;
  const days = new Date(year, month, 0).getDate();
  for (let i = 1; i <= days; i += 1) {
    result.push(`${year}-${String(month).padStart(2, '0')}-${String(i).padStart(2, '0')}`);
  }
  return result;
};
